
let baseURL = 'https://s2.vivivi.club'


const http = (method = 'get', url, param) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseURL+'/index/'+url,
			data: param,
			method:method,
			timeout:9000,
			dataType:'json',
			sslVerify:false,
			header: {
				'token': uni.getStorageSync('token') || '',
				'Accept': 'application/json',
				'Content-Type': 'application/json'
			},
			success: (response) => {
				const data = response.data
				if (data.code === 0) {
					uni.showToast({
						title:data.msg,
						duration:1200,
						icon: 'none'
					})
				}
				// console.log(444,data)
				resolve(data)
			},
			fail: (err) => {
				console.error('fail',err);
				reject(err)
			},
			complete: (res) => {
			}
		});
	})
}

export {
	http,
	baseURL
}
